<?php
if (!defined('admin')) {
    exit();
}
if (get_admin_level() < 2) adminmsg('', "您没有操作的权限");
$lastbacktime = session_get('backuptime');
echo $lastbacktime, ' ', time();
if (!$lastbacktime) {
    $lastbacktime = 0;
}

if (time() - $lastbacktime < 60 * 10) {
    adminmsg('', '操作过于频繁，请等待' . (11 - intval((time() - $lastbacktime) / 60)) . '分钟后再试');
} else {

    $bakfile = M()->backup();
    log_todb("操作日志", getadminname() . "进行了数据库备份：" . file_name($bakfile));
    session_set('backuptime', time());
    adminmsg('', '备份完成，文件保存在：<code>' . DBDir . 'backup/' . file_name($bakfile) . '</code>', 10, '数据库备份');
}
